<div class="view">

	<table class="collapse">
		<tr>
			<td class="top">
				<div class="span-4 center">
					<?php
					$default = Yii::app()->request->hostInfo;
					$default .= Yii::app()->getModule('qa')->assetsUrl;
					$default .= '/images/gravatar-150.png';
					$firstname = $data->creator->profile->firstname;
					$config = array(
						'email'=>$data->creator->email,
						'hashed'=>false,
						'default'=>$default,
						'size'=>150,
						'rating'=>'PG',
						'htmlOptions'=>array(
							'alt'=>"$firstname Avatar",
							'title'=>CHtml::encode($firstname),
							'class'=>'round stroke'
						),
					);
					$this->widget('qa.widgets.GravatarWidget', $config);
					?>
					<div>
						<b>
							<?php echo CHtml::encode($firstname); ?>
						</b>
					</div>
				</div>

				<div class="clear"></div>
			</td>
			<td class="full top">
				<div class="flash-info round">
					<b><?php echo CHtml::encode($data->title); ?></b>
					<div class="small bottom negative">
						<?php
						echo Yii::app()->dateFormatter->formatDateTime(
							$data->unixCreatedAt, 'full', 'short'
						);
						?>
					</div>
				</div>

				<div>
					<?php
					$properties = array('purifyOutput'=>true);
					$this->beginWidget('CMarkdown', $properties);
					echo $data->value;
					$this->endWidget();
					?>
				</div>

				<div class="small bottom prepend-top">
					Views <?php echo Yii::app()->format->number($data->viewCount) ?>&times;
					with
					<?php
					if ($data->answerCount) {
						$plural = $data->answerCount > 1 ? 'replies' : 'reply';
						$text = "$data->answerCount $plural";
					} else {
						$text = 'No reply';
					}
					echo "$text<br />";

					if ($data->answerCount) {
						echo "Last reply by " . $data->updater->profile->firstname;
						echo ' at ';
						$formatter = Yii::app()->dateFormatter;
						echo $formatter->formatDateTime(
							$data->unixUpdatedAt, 'medium', 'short'
						);
					}
					?>
				</div>

				<div class="right">
					<?php
					$user = Yii::app()->user;
					if (!$user->isGuest) {
						if ($user->id == 1 || $user->id == $data->createdBy) {
							$url = array('update', 'id'=>$data->id);
							$htmlOptions = array(
								'class'=>'button negative round'
							);
							echo CHtml::link('Update', $url, $htmlOptions);
						}
					}
					
					$url = array('view', 'id'=>$data->id);
					$htmlOptions = array(
						'class'=>'button positive round last'
					);
					echo CHtml::link('View', $url, $htmlOptions);
					?>
				</div>

				<div class="clear"></div>
			</td>
		</tr>
	</table>

</div>